package com.utf999.qiangmanger.entity.orm;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.utf999.qiangmanger.entity.UUIDEntity;

/**
 * 商品信息。前期，商品信息的查询使用数据库查询完成；后期改用搜索引擎，数据库中的记录只作为数据依据
 * @author yinwenjie
 * @index companyname_sortname  unique (company,sortname)
 * @index companyname_commodityname  unique (company,commodityname)
 * @index companyname_commoditycode  unique (company,commoditycode)
 */
@Entity
@Table(name="B_Commodity")
public class CommodityEntity extends UUIDEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1896999254898348627L;
	
	/**
	 * 商品所属的公司信息
	 */
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="company" , nullable=false)
	private CompanyEntity company;
	
	/**
	 * 商品所属的分类信息。为了简单起见，一个商品只属于一类目录
	 */
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="commodityType" , nullable=false)
	private CommodityTypeEntity commodityType;
	
	/**
	 * 商品编号。同一个公司下，商品编号不能重复
	 */
	@Column(name="commodityCode" , length=128 , nullable=false)
	private String commodityCode;
	
	/**
	 * 商品名称；同一个公司下，商品名称不允许重复
	 */
	@Column(name="commodityName" , length=128 , nullable=false)
	private String commodityName;
	
	/**
	 * 商品简称。同一个公司下，商品简称不允许重复
	 */
	@Column(name="sortName" , length=64 , nullable=false)
	private String sortName;
	
	/**
	 * 商品的创建时间
	 */
	@Column(name="createTime" , nullable=false)
	private Date createTime;
	
	/**
	 * 商品的状态：<br>
	 * 1、正常；0：作废或者已下架
	 */
	@Column(name="status" , nullable=false)
	private Integer status;
	
	/**
	 * 商品说明（可能没有）
	 */
	@Column(name="remark" , length=256 , nullable=false)
	private String remark;
	
	public CompanyEntity getCompany() {
		return company;
	}

	public void setCompany(CompanyEntity company) {
		this.company = company;
	}

	public CommodityTypeEntity getCommodityType() {
		return commodityType;
	}

	public void setCommodityType(CommodityTypeEntity commodityType) {
		this.commodityType = commodityType;
	}

	public String getCommodityCode() {
		return commodityCode;
	}

	public void setCommodityCode(String commodityCode) {
		this.commodityCode = commodityCode;
	}

	public String getCommodityName() {
		return commodityName;
	}

	public void setCommodityName(String commodityName) {
		this.commodityName = commodityName;
	}

	public String getSortName() {
		return sortName;
	}

	public void setSortName(String sortName) {
		this.sortName = sortName;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	/* (non-Javadoc)
	 * @see com.utf999.qiangmanger.entity.UUIDEntity#getUniqueKey()
	 */
	@Override
	public String getUniqueKey() {
		return "uid";
	}

}
